package com.mt.mtyx.home.service.impl;

import com.mt.mtyx.entity.product.Category;
import com.mt.mtyx.entity.product.SkuInfo;
import com.mt.mtyx.entity.search.SkuEs;
import com.mt.mtyx.home.service.HomeService;
import com.mt.mtyx.product.ProductFeignClient;
import com.mt.mtyx.search.SkuFeignClient;
import com.mt.mtyx.user.UserFeignClient;
import com.mt.mtyx.vo.user.LeaderAddressVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author WMT
 * @Date 2023/9/21 17:06
 */
@Service
public class HomeServiceImpl implements HomeService {

    @Autowired
    private UserFeignClient userFeignClient;

    @Autowired
    private ProductFeignClient productFeignClient;

    @Autowired
    private SkuFeignClient skuFeignClient;

    @Override
    public Map<String, Object> getHomeData(Long userId) {
        Map<String, Object> result = new HashMap<>(4);
        // 1.根据当前登录用户id获取提货地址信息
        LeaderAddressVo leaderAddressVo = userFeignClient.getLeaderAddressByUserId(userId);
        result.put("leaderAddressVo", leaderAddressVo);
        // 2.获取所有分类
        List<Category> allCategoryList = productFeignClient.getAllCategoryList();
        result.put("categoryList", allCategoryList);
        // 3.获取新人专享商品
        List<SkuInfo> newPersonSkuInfoList = productFeignClient.getNewPersonSkuInfoList();
        result.put("newPersonSkuInfoList", newPersonSkuInfoList);
        // 4.获取爆款商品
        List<SkuEs> hotSkuList = skuFeignClient.getHotSkuList();
        result.put("hotSkuList", hotSkuList);
        return result;
    }
}
